home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / parsed / selfile.frm < prev    next >
Text File  |  1995-05-02  |  4KB  |  142 lines

  1. VERSION 2.00
  2. Begin Form frmSelFile 
  3.    Caption         =   "Select Text File To Load"
  4.    ClientHeight    =   4635
  5.    ClientLeft      =   1515
  6.    ClientTop       =   840
  7.    ClientWidth     =   6285
  8.    Height          =   5040
  9.    Left            =   1455
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4635
  12.    ScaleWidth      =   6285
  13.    Top             =   495
  14.    Width           =   6405
  15.    Begin CommandButton cmdLoad 
  16.       Caption         =   "&Load File"
  17.       Height          =   375
  18.       Left            =   1815
  19.       TabIndex        =   2
  20.       Top             =   3840
  21.       Width           =   2340
  22.    End
  23.    Begin TextBox txtPattern 
  24.       Height          =   315
  25.       Left            =   435
  26.       TabIndex        =   6
  27.       Top             =   450
  28.       Width           =   2355
  29.    End
  30.    Begin TextBox txtFile 
  31.       Height          =   315
  32.       Left            =   420
  33.       TabIndex        =   7
  34.       Top             =   3420
  35.       Width           =   5115
  36.    End
  37.    Begin DriveListBox Drive1 
  38.       Height          =   315
  39.       Left            =   2940
  40.       TabIndex        =   5
  41.       Top             =   510
  42.       Width           =   2535
  43.    End
  44.    Begin DirListBox Dir1 
  45.       Height          =   1830
  46.       Left            =   2940
  47.       TabIndex        =   1
  48.       Top             =   1050
  49.       Width           =   2535
  50.    End
  51.    Begin FileListBox File1 
  52.       Height          =   2175
  53.       Left            =   450
  54.       TabIndex        =   0
  55.       Top             =   870
  56.       Width           =   1905
  57.    End
  58.    Begin Label Label2 
  59.       Caption         =   "Current File:"
  60.       Height          =   255
  61.       Left            =   450
  62.       TabIndex        =   4
  63.       Top             =   3120
  64.       Width           =   1755
  65.    End
  66.    Begin Label Label1 
  67.       Caption         =   "File Patterns:"
  68.       Height          =   255
  69.       Left            =   480
  70.       TabIndex        =   3
  71.       Top             =   90
  72.       Width           =   1290
  73.    End
  74. End
  75.  
  76. Sub cmdLoad_Click ()
  77.    Dim FileNam$, FileContents$, msg$
  78.    Dim FileLength&
  79.  
  80.    Screen.MousePointer = HOURGLASS
  81.    'get file name and length of selected file
  82.    FileNam$ = Trim$(txtFile)
  83.    FileLength& = FileLen(FileNam$)
  84.  
  85.    'bail if file too big
  86.    If FileLength& > 28000 Then
  87.       msg$ = "The file you selected is too large. Please try another file."
  88.       MsgBox msg$, MB_ICONINFORMATION
  89.       Screen.MousePointer = DEFAULT
  90.       File1.SetFocus
  91.    Else
  92.       'load file and put contents into txtFileContents on frmParse
  93.       FileContents$ = LoadFile$(Trim$(txtFile), FileLength&)
  94.       frmParse!txtFileContents = FileContents$
  95.       'display filename on frmParse
  96.       frmParse!lblFileName = FileNam$
  97.       'display file length info on frmParse
  98.       frmParse!lblFileLen = "Length of File: " & Format$(FileLength&, "##,###") & " bytes."
  99.       Unload Me
  100.    End If
  101. End Sub
  102.  
  103. Sub Dir1_Change ()
  104.     File1.Path = Dir1.Path
  105. End Sub
  106.  
  107. Sub Dir1_Click ()
  108.     txtFile.Text = ""
  109. End Sub
  110.  
  111. Sub Drive1_Change ()
  112.     Dir1.Path = Drive1.Drive
  113. End Sub
  114.  
  115. Sub File1_Click ()
  116.     Dim i%
  117.  
  118.     For i% = 0 To File1.ListCount - 1
  119.         If File1.Selected(i%) = True Then
  120.             If Right$(Dir1.Path, 1) = "\" Then
  121.                 txtFile = File1.Path & File1.List(i%)
  122.             Else
  123.                 txtFile = File1.Path & "\" & File1.List(i%)
  124.             End If
  125.             Exit For
  126.         End If
  127.     Next i%
  128.     If txtFile <> "" Then cmdLoad.SetFocus
  129. End Sub
  130.  
  131. Sub Form_Activate ()
  132.    Screen.MousePointer = DEFAULT
  133. End Sub
  134.  
  135. Sub Form_Load ()
  136.     Drive1.Drive = "D:\"
  137.     File1.Path = Dir1.Path
  138.     File1.Pattern = "*.txt"
  139.     txtPattern = File1.Pattern
  140. End Sub
  141.  
  142.